﻿using log4net;
using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;

namespace WLYT.Admin.WebApi.Component.Quartz
{
    [DisallowConcurrentExecution]
    public class CronTask : IJob
    {
        private static readonly ILog loginfo = LogManager.GetLogger("loginfo");
        public string TaskName { get; set; }
        public Task Execute(IJobExecutionContext context)
        {
            try
            {
                return Task.Factory.StartNew(() =>
                {
                    loginfo.Info(TaskName + "正在执行");
                });
                //JobDataMap dataMap = context.MergedJobDataMap;
                //string tag = dataMap.GetString("tag");
                // ... do work
            }
            catch (Exception ex)
            {
                // do you want the job to refire?
                throw new JobExecutionException(msg: "", refireImmediately: true, cause: ex);
            }
        }
    }
}